package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 课程类型
 * <p>
 * Created by lx on 2019/1/28.
 */
@Getter
@AllArgsConstructor
public enum CourseStatusEnum {

    SAVE(1, "保存"),
    SHARED(2, "共享"),
    SHARED_AND_NOT_VIEWED(3, "未购买");

    private Integer code;

    private String message;

    public static CourseStatusEnum getByCode(Integer code) {
        for (CourseStatusEnum courseStatusEnum : CourseStatusEnum.values()) {
            if (Objects.equals(courseStatusEnum.getCode(), code)) {
                return courseStatusEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        CourseStatusEnum courseStatusEnum = getByCode(code);
        return courseStatusEnum == null ? null : courseStatusEnum.getMessage();
    }

}
